var express = require('express');
var router = express.Router();
var NewsModel=require('../models/news.model');
var iconv = require('iconv-lite');
router.get('/', function(req, res, next) {
    var params=req.body;
    res.render('news/list.html', { title:'list' });
});
router.get('/list-data/:page', function(req, res, next) {
  var args=req.query;
  NewsModel.getList(args,function(error,result,total){
      res.json({total:total,rows:result})
  })
});
router.get('/detail/:id', function(req, res, next) {
    var params=req.params;
    NewsModel.getDetail(params.id,function(error,result){
        //res.json(result)
        res.render('news/detail.html', { title:result[0].title,data:result });
    })
});

module.exports = router;
